package com.fh.service.system.student;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.entity.system.Student;
import com.fh.entity.system.User;
import com.fh.util.PageData;


@Service("studentService")
public class StudentService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	/*
	* 新增
	*/
	public void save(PageData pd)throws Exception{
		dao.save("StudentMapper.save", pd);
	}
	
	/*
	* 删除
	*/
	public void delete(PageData pd)throws Exception{
		dao.delete("StudentMapper.delete", pd);
	}
	
	/*
	* 修改
	*/
	public void edit(PageData pd)throws Exception{
		dao.update("StudentMapper.edit", pd);
	}

	/*
	* 修改
	*/
	public void editByUsername(PageData pd)throws Exception{
		dao.update("StudentMapper.editByUsername", pd);
	}

	/*
	*列表
	*/
	public List<PageData> list(Page page)throws Exception{
		return (List<PageData>)dao.findForList("StudentMapper.datalistPage", page);
	}
	
	/*
	*列表(全部)
	*/
	public List<PageData> listAll(PageData pd)throws Exception{
		return (List<PageData>)dao.findForList("StudentMapper.listAll", pd);
	}

	/*
	* 通过id获取数据
	*/
	public PageData findById(PageData pd)throws Exception{
		return (PageData)dao.findForObject("StudentMapper.findById", pd);
	}
	/*
	* 通过USERNAME获取数据
	*/
	public PageData findByUsername(PageData pd)throws Exception{
		return (PageData)dao.findForObject("StudentMapper.findByUsername", pd);
	}
	/*
	* 批量删除
	*/
	public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
		dao.delete("StudentMapper.deleteAll", ArrayDATA_IDS);
	}
	/*
	* 保存用户IP
	*/
	public void saveIP(PageData pd)throws Exception{
		dao.update("StudentXMapper.saveIP", pd);
	}
	/*
	* 登录判断
	*/
	public PageData getStudentByNameAndPwd(PageData pd)throws Exception{
		return (PageData)dao.findForObject("StudentXMapper.getStudentInfo", pd);
	}
	/*
	* 跟新登录时间
	*/
	public void updateLastLoginTime(PageData pd)throws Exception{
		dao.update("StudentXMapper.updateLastLoginTime", pd);
	}
	/*
	*通过id获取数据
	*/
	public Student getStudentAndRoleById(String STUDENT_ID) throws Exception {
		return (Student) dao.findForObject("StudentMapper.getStudentAndRoleById", STUDENT_ID);
	}
	
}

